#include <rtthread.h>
#include "bsp_pin.h"
extern void bsp_KeyScan10ms(void);

/* 定时器的控制块 */
static rt_timer_t timer1;

/* 定时器 1 超时函数 */
static void keyscan_timeout(void *parameter)
{
    bsp_KeyScan10ms();
}


/* 检查，清理上次的定时器 */
static void check_timer_exist(void)
{
    if (timer1 != RT_NULL)
    {
        rt_timer_delete(timer1);
        timer1 = RT_NULL;
    }
}

int keyscan_sftimer_new(void)
{
    /* 检查，清理上次的定时器 */
    check_timer_exist();

    /* 创建定时器 1  周期定时器 */
    timer1 = rt_timer_create("timer1", keyscan_timeout,
                             RT_NULL, 10,
                             RT_TIMER_FLAG_PERIODIC);

    /* 启动定时器 1 */
    if (timer1 != RT_NULL) 
		{
			rt_timer_start(timer1);
		}
		return 0;
}


void idle_hook_fn(void)
{
    bsp_PinToggle(LED1);
}

void scheduler_hook_fn(struct rt_thread* from,struct rt_thread* to)
{
    rt_kprintf("from: %s ---> to: %s\n",from->name,to->name);
};

